package com.study.studyroom.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.study.studyroom.constant.ApiConstant;
import com.study.studyroom.entity.bo.OrderBo;
import com.study.studyroom.entity.bo.RequestResult;
import com.study.studyroom.entity.vo.Condition;
import com.study.studyroom.entity.vo.order.OrderSearchVo;
import com.study.studyroom.entity.vo.order.OrderVo;
import com.study.studyroom.service.OrderService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping(ApiConstant.API_V1+"order")
public class OrderController {
    private final OrderService orderService;
    @ApiOperation("创建订单")
    @PostMapping("/createOrder")
    public RequestResult<Integer> createOrder(@RequestBody OrderVo orderVo){
        return RequestResult.success(orderService.createOrder(orderVo));
    }

    @ApiOperation("获取订单")
    @PostMapping("/getOrder")
    public RequestResult<IPage<OrderBo>> getOrder(@RequestBody Condition<OrderSearchVo> condition){
        return RequestResult.success(orderService.getOrder(condition));
    }

    @ApiOperation("更新订单状态")
    @GetMapping("/updateOrderStatus")
    public RequestResult<OrderBo> updateOrderStatus(String id){
        return RequestResult.success(orderService.updateOrderStatus(id));
    }
}
